//
//  ICBaseView.swift
//  IndustryNet
//
//  Created by topnet on 2022/1/20.
//

import UIKit

class ICBaseView: UIView {

    var autoBottomInset: CGFloat = 0
    ///设置autoHeight 必须设置lastV
    var lastV: UIView?
    
    func initFrame() {
        subviews.forEach { v in
            if let v = v as? ICBaseView {
                v.initFrame()
            }
        }
    }
    ////autoHeight 必须设置lastV
    func autoHeight() {
        guard let _lastV = lastV ?? subviews.last else { return }
        if let _lastV = _lastV as? ICBaseView {
            if _lastV.lastV != nil {
                _lastV.autoHeight()
            }
        }
        height(_lastV.frame.maxY + autoBottomInset)
    }
    
    func _initUI() {}
    func _initData() {}
    
    required init() {
        super.init(frame: .zero)
        _initUI()
        _initData()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
